home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / telecomm / t100.zoo / font.c < prev    next >
C/C++ Source or Header  |  1991-09-15  |  3KB  |  140 lines

  1. #undef __NO_INLINE__
  2.  
  3.  
  4. /*
  5.  *    font.c
  6.  */
  7.  
  8. #ifndef lint
  9. static char *rcsid_font_c = "$Id: font.c,v 1.0 1991/09/12 20:32:56 rosenkra Exp $";
  10. #endif
  11.  
  12. /*
  13.  * $Log: font.c,v $
  14.  * Revision 1.0  1991/09/12  20:32:56  rosenkra
  15.  * Initial revision
  16.  *
  17.  */
  18.  
  19.  
  20. /*
  21.  *    this is a set of routines to allow for changing fonts. what we do
  22.  *    here will work in all resolutions, though the font data included
  23.  *    below is only for high rez. this uses line A. it only supports the
  24.  *    monospaced font, which is fine for things like nroff.
  25.  *
  26.  *    load_msp_font (int opt, int *pfdar)
  27.  *            load a font (used by the others)
  28.  *
  29.  *    front ends to load_msp_font:
  30.  *
  31.  *    fnt_bold ()    set bold font (provides data)
  32.  *    fnt_uline ()    set underline font (provides data)
  33.  *    fnt_reverse ()    set reverse (standout) font (provides data)
  34.  *    fnt_roman ()    set roman font (provides data)
  35.  *    fnt_normal ()    set normal font (reset to orig sys font)
  36.  */
  37.  
  38. #include <stdio.h>            /* for NULL only */
  39. #include <linea.h>
  40. #include <osbind.h>
  41.  
  42.  
  43.  
  44. /*------------------------------*/
  45. /*    load_msp_font        */
  46. /*------------------------------*/
  47. int load_msp_font (opt, pfdar)
  48. int    opt;                /* 0=init, 1=set, 2=reset to orig */
  49. short  *pfdar;                /* new font data */
  50. {
  51.  
  52. /*
  53.  *    load a new monospaced font (8x16 only now)
  54.  *
  55.  *    opt=0        save original data (uses static variables)
  56.  *            this is also done if it was not done before
  57.  *    opt=1        set new font
  58.  *    opt=2        reset back to (saved) original data
  59.  *
  60.  *    what we do is change 2 pointers: 1) the fnt_dta ptr in the DEF_FONT
  61.  *    header, and 2) the ptr to the monospaced font data. we get the info
  62.  *    from line A.
  63.  */
  64.  
  65.     static short           *origfhdat = 0L;    /* saved DEF_FONT->dat_table */
  66.     static short           *origmspdat = 0L;/* saved V_FNT_AD */
  67.     static long        A_ptr = 0L;
  68.  
  69.     long               *pltmp;
  70.     long            ltmp;
  71.     long            saveptr;
  72.     __FONT               *pfnthdr;
  73.  
  74.  
  75.  
  76.     /*
  77.      *   everything we need is based on line A. get ptr to its struct
  78.      */
  79.     if (A_ptr == 0)
  80.     {
  81.         linea0 ();
  82.         A_ptr = (long) __aline;
  83.     }
  84.  
  85.  
  86.     /*
  87.      *   if we did not already save the original ptrs (fnt_dta in
  88.      *   DEF_FONT header and V_FNT_AD, the monospaced font), do so...
  89.      */
  90.     if ((origfhdat == (short *) NULL) && (origmspdat == (short *) NULL))
  91.     {
  92.         saveptr    = (long) Super (0L);
  93.  
  94.         ltmp       = *(long *) ((long) A_ptr - 460L);    /* DEF_FONT */
  95.         pfnthdr    = (__FONT *) (ltmp);
  96.         origfhdat  = (short *) (pfnthdr->dat_table);
  97.         ltmp       = *(long *) ((long) A_ptr - 22L);    /* V_FNT_AD */
  98.         origmspdat = (short *) (ltmp);
  99.  
  100.         Super (saveptr);
  101.     }
  102.  
  103.  
  104.     /*
  105.      *   if we are just initializing, return
  106.      */
  107.     if (opt == 0)
  108.         return;
  109.  
  110.  
  111.     /*
  112.      *   what are we here for?
  113.      */
  114.     switch (opt)
  115.     {
  116.     case 1:                /* set new font */
  117.         saveptr            = (long) Super (0L);
  118.         pltmp              = (long *) ((long) A_ptr - 460L);
  119.         pfnthdr            = (__FONT *) (*pltmp);
  120.         pfnthdr->dat_table = (char *) pfdar;
  121.         pltmp              = (long *) ((long) A_ptr - 22L);
  122.         *pltmp             = (long) pfdar;
  123.         Super (saveptr);
  124.         break;
  125.  
  126.     case 2:                /* reset orig */
  127.         saveptr            = (long) Super (0L);
  128.         pltmp              = (long *) ((long) A_ptr - 460L);
  129.         pfnthdr            = (__FONT *) (*pltmp);
  130.         pfnthdr->dat_table = (char *) origfhdat;
  131.         pltmp              = (long *) ((long) A_ptr - 22L);
  132.         *pltmp             = (long) origmspdat;
  133.         Super (saveptr);
  134.         break;
  135.     }
  136.  
  137.     return;
  138. }
  139.  
  140.